// class QrDetail extends StatelessWidget {

// }
import 'package:date_format/date_format.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:my_app/common/common.dart';
import 'package:my_app/global/global.dart';
import 'package:my_app/service/api/api.dart';
import 'package:dart_date/dart_date.dart';

class QrDetail extends StatefulWidget {
  final String qrCode;
  final String isEdit;

  QrDetail({Key? key, required this.qrCode, required this.isEdit})
      : super(key: key);

  @override
  State<QrDetail> createState() =>
      _QrDetailState(qrCode: this.qrCode, isEdit: this.isEdit);
}

class _QrDetailState extends State<QrDetail> {
  // final String? goodsCode;
  // const QrDetail({Key? key, this.listDataPage}) : super(key: key);
  _QrDetailState({required String this.qrCode, required String this.isEdit});
  final qrCode;
  final isEdit;
  // String qrCode = "";
  String generateDate = ""; // 生成日期
  String supplierNumber = ""; // 供应商编号
  String supplierName = ""; // 供应商名称
  String goodsCode = ""; // 商品条码
  String unit = ""; // 单位
  String goodsName = ""; // 商品名称
  String norm = ""; // 规格
  String generateLocation = ""; // 产地
  String shelfLife = ""; // 保质期
  String generateCompany = ""; // 生成商
  String productionDate = ""; // 生产日期
  String maturityDate = ""; // 到期日期
  String checkImg = ""; // 质检报告
  String shelfLifeUnit = ""; // 保质期单位
  bool _showImg = true;
  bool _isChange = true; // 保质期、生产日期只有在接口返回中的”CKDG_FLG”不为”已入库”的情况下可以修改
  DateTime _selectedDate = DateTime.now(); //当前选中的日期
  TextEditingController _goodsController = new TextEditingController();
  FocusNode _goodsfocusNode = FocusNode();
  TextEditingController _shelfLifeController = new TextEditingController();
  FocusNode _shelfLifefocusNode = FocusNode();
  String imgId = "";
  int _status = 0; // 状态选择值
  Color disableColor = Colors.white;
  @override
  initState() {
    getData();
    super.initState();
    _goodsfocusNode.addListener(() {
      if (_goodsfocusNode.hasFocus) {
        // SystemChannels.textInput.invokeMethod('TextInput.hide');
        print('得到焦点');
      } else {
        print('失去焦点');
        if (_goodsController.text != goodsCode) {
          // 条码改变商品条码func
          changeGoods(_goodsController.text);
        } else {
          print("商品条码未变化");
        }
      }
    });
    _shelfLifefocusNode.addListener(() {
      if (_shelfLifefocusNode.hasFocus) {
        // SystemChannels.textInput.invokeMethod('TextInput.hide');
        print('得到焦点');
      } else {
        print('失去焦点');
        // 改变到期日期
        getMaturityDate();
        // print(formatDate(
        // DateTime.now().add(new Duration(days: _shelfLifeController.text)), [yyyy, "-", mm, "-", "dd"]));
        // if (_goodsController.text != goodsCode) {
        //   // 条码改变商品条码func
        //   changeGoods(_goodsController.text);
        // } else {
        //   print("商品条码未变化");
        // }
      }
    });
    // print(formatDate(
    //     DateTime.now().add(new Duration(days: 1)), [yyyy, "-", mm, "-", "dd"]));
    // Map userinfo = {"userName":"张三","age":20};
  }

  // 生产日期icon 宽度控制
  double getIconWidth() {
    MediaQueryData mq;
    mq = MediaQuery.of(context);
    // 设备宽度
    double deviceWidth = mq.size.width;
    double width = 210;
    if (deviceWidth > 360) {
      width = 140;
    } else {
      width = mq.size.width - 120;
    }
    return width;
  }

  double getFromWidth() {
    MediaQueryData mq;
    mq = MediaQuery.of(context);
    // 设备宽度
    double deviceWidth = mq.size.width;
    double width = 210;
    if (deviceWidth > 360) {
      width = 190;
    } else {
      width = mq.size.width - 80;
    }
    return width;
  }

  double getWidth() {
    MediaQueryData mq;
    mq = MediaQuery.of(context);
    // 设备宽度
    double deviceWidth = mq.size.width;
    double width = 210; // 列表内容大小
    if (deviceWidth > 360) {
      width = 450;
    } else {
      width = 260;
    }
    return width;
  }

  double getfontSize() {
    MediaQueryData mq;
    mq = MediaQuery.of(context);
    // 设备宽度
    double deviceWidth = mq.size.width;
    double fontSize = 11; // 列表内容大小
    if (deviceWidth > 360) {
      fontSize = 11;
    } else {
      fontSize = 8;
    }
    return fontSize;
  }

  @override
  void dispose() {
    super.dispose();
    //释放
    _goodsfocusNode.dispose();
    _shelfLifefocusNode.dispose();
  }

  // 计算到期日期
  void getMaturityDate() {
    var dentistAppointment;
    if (_status == 0) {
      dentistAppointment = formatDate(
          new DateTime(
            int.parse(productionDate.substring(0, 4)),
            int.parse(productionDate.substring(5, 7)),
            int.parse(productionDate.substring(8, 10)),
          ).add(new Duration(days: int.parse(_shelfLifeController.text) - 1)),
          [yyyy, "-", mm, "-", "dd"]);
    } else if (_status == 1) {
      dentistAppointment = formatDate(
          new DateTime(
            int.parse(productionDate.substring(0, 4)),
            int.parse(productionDate.substring(5, 7)),
            int.parse(productionDate.substring(8, 10)),
          ).addMonths(int.parse(_shelfLifeController.text)).subDays(1),
          [yyyy, "-", mm, "-", "dd"]);
    } else if (_status == 2) {
      dentistAppointment = formatDate(
          new DateTime(
            int.parse(productionDate.substring(0, 4)),
            int.parse(productionDate.substring(5, 7)),
            int.parse(productionDate.substring(8, 10)),
          ).addYears(int.parse(_shelfLifeController.text)).subDays(1),
          [yyyy, "-", mm, "-", "dd"]);
    }

    setState(() {
      maturityDate = dentistAppointment;
      shelfLife = _shelfLifeController.text;
      _shelfLifeController.text;
    });
  }

  // 获取详情数据
  void getData() async {
    var data = await ApiService.getDetailData(qrCode);
    print("_______________获取详情页面数据______________________");
    print(data);
    if (data != null && data.length > 0) {
      if (data[0]["IMG_ID"] != null && data[0]["IMG_ID"] != "") {
        var imgData = await ApiService.getDetailImg(data[0]["IMG_ID"]);
        _showImg = false;
        checkImg = imgData;
        print(imgData);
      }
      if (data[0]["SHELF_LIFE_UNIT"] == "天") {
        _status = 0;
      } else if (data[0]["SHELF_LIFE_UNIT"] == "个月") {
        _status = 1;
      } else if (data[0]["SHELF_LIFE_UNIT"] == "年") {
        _status = 2;
      }
      setState(() {
        imgId = data[0]["IMG_ID"];
        generateDate = data[0]["CODE_DT"];
        supplierNumber = data[0]["VENDOR_ID"];
        supplierName = data[0]["VENDOR_NAME"];
        goodsCode = data[0]["ITEM_ID"];
        _goodsController.text = data[0]["ITEM_ID"];
        unit = data[0]["BASE_UNIT"];
        goodsName = data[0]["ITEM_NAME"];
        norm = data[0]["MUJI_SIZE"];
        generateLocation = data[0]["ORIGIN"];
        // if (data[0]["SHELF_LIFE"] != "") {
        shelfLife = data[0]["SHELF_LIFE"];
        shelfLifeUnit = data[0]["SHELF_LIFE_UNIT"];
        _shelfLifeController.text = data[0]["SHELF_LIFE"];
        // _shelfLifeController.text = "123";
        // }
        // } else {
        //   shelfLife = "1";
        // }

        //generateCompany = data[0]["ITEM_NAME"];
        if (data[0]["BATCH_DT"] != "") {
          productionDate = data[0]["BATCH_DT"];
        } else {
          productionDate = DateTime.now().toString().substring(0, 10);
        }

        if (data[0]["CKDG_FLG"] != "已入库" && this.isEdit != "未赋码") {
          _isChange = false;
        }
        if (data[0]["CKDG_FLG"] == "已入库" || this.isEdit == "未赋码") {
          disableColor = Colors.black12;
        }
        // 到期日为空时 = 生成日期+保质期
        if (data[0]["END_DT"] != "") {
          maturityDate = data[0]["END_DT"];
        } else {
          if (data[0]["SHELF_LIFE"] == "") {
            maturityDate = "";
          } else {
            if (_status == 0) {
              var dentistAppointment = formatDate(
                  new DateTime(
                    int.parse(productionDate.substring(0, 4)),
                    int.parse(productionDate.substring(5, 7)),
                    int.parse(productionDate.substring(8, 10)),
                  ).add(new Duration(days: int.parse(shelfLife) - 1)),
                  [yyyy, "-", mm, "-", "dd"]);
              print("dentistAppointment");
              print(dentistAppointment);
              maturityDate = dentistAppointment;
            } else if (_status == 1) {
              var dentistAppointment = formatDate(
                  new DateTime(
                    int.parse(productionDate.substring(0, 4)),
                    int.parse(productionDate.substring(5, 7)),
                    int.parse(productionDate.substring(8, 10)),
                  ).addMonths(int.parse(data[0]["SHELF_LIFE"])).subDays(1),
                  [yyyy, "-", mm, "-", "dd"]);
              print("dentistAppointment");
              print(dentistAppointment);
              maturityDate = dentistAppointment;
            } else if (_status == 1) {
              var dentistAppointment = formatDate(
                  new DateTime(
                    int.parse(productionDate.substring(0, 4)),
                    int.parse(productionDate.substring(5, 7)),
                    int.parse(productionDate.substring(8, 10)),
                  ).addYears(int.parse(data[0]["SHELF_LIFE"])).subDays(1),
                  [yyyy, "-", mm, "-", "dd"]);
              print("dentistAppointment");
              print(dentistAppointment);
              maturityDate = dentistAppointment;
            }
          }

          //  productionDate;
        }
      });
    }
  }

  // 修改商品条码
  void changeGoods(String goods) async {
    var _prDate = productionDate.substring(0, 4) +
        productionDate.substring(5, 7) +
        productionDate.substring(8);
    print(_prDate);
    var data = await ApiService.changeGoodsCode(goods, supplierNumber, _prDate);
    if (data.length > 0) {
      // 详情数据
      //商品条码,商品名称,单位,规格,产地,保质期
      setState(() {
        goodsCode = data[0]["ITEM_ID"];
        goodsName = data[0]["ITEM_NAME"];
        unit = data[0]["BASE_UNIT"];
        generateLocation = data[0]["ORIGIN"];
        shelfLife = data[0]["SHELF_LIFE"];
        _shelfLifeController.text = data[0]["SHELF_LIFE"];
      });
    } else {
      Common.showTost("商品不存在");
    }
    print(data);
  }

  // 保存详情数据
  void saveData() async {
    if (_status == 0) {
      shelfLifeUnit = "天";
    } else if (_status == 1) {
      shelfLifeUnit = "个月";
    } else if (_status == 2) {
      shelfLifeUnit = "年";
    }
    var data = await ApiService.saveDetailData(
        qrCode,
        goodsCode,
        unit,
        norm,
        generateLocation,
        shelfLife,
        productionDate,
        maturityDate,
        imgId,
        shelfLifeUnit);
    print("_______________保存详情数据______________________");
    print(data);
    if (data == "1:成功") {
      Navigator.of(context).pop();
    } else {
      Future.delayed(Duration(milliseconds: 5000), () {
        Common.showTost(data);
      });
    }
  }

  // alert
  alertDialog(String content, [String title = "提示信息！"]) {
    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text(title),
            content: Text(content),
            actions: <Widget>[
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: Text("取消"),
              ),
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                  saveData();
                },
                child: Text("确定"),
              )
            ],
          );
        });
  }

  @override
  Widget build(BuildContext context) {
    //调起日期选择器
    _showDatePicker() {
      //获取异步方法里面的值的第一种方式：then
      showDatePicker(
        //如下四个参数为必填参数
        context: context,
        initialDate: _selectedDate, //选中的日期
        firstDate: DateTime(1980), //日期选择器上可选择的最早日期
        lastDate: DateTime(2100), //日期选择器上可选择的最晚日期
      ).then((selectedValue) {
        setState(() {
          //将选中的值传递出来
          this._selectedDate = selectedValue!;
          productionDate =
              formatDate(this._selectedDate, [yyyy, "-", mm, "-", "dd"]);
          // this._selectedDate,
          // [HH, ':', nn, ':', ss]);
        });
      });
    }

    TextStyle textStyle = TextStyle(fontSize: 10);
    double textWidth = 50; // label 宽度
    double inputHeigt = 25; // input 高度
    // button 文字样式
    TextStyle _buttonTextStyle = TextStyle(
      fontSize: 10.0,
      color: Colors.white,
    );
    // button 样式
    ButtonStyle _buttonStyle = TextButton.styleFrom(
      backgroundColor: Color(Common.muji),
      padding: EdgeInsets.all(5),
    );

    return Scaffold(
      appBar: AppBar(
        title: Text("详情"),
        centerTitle: true,
        backgroundColor: Color(Common.muji),
        leading: IconButton(
          tooltip: '返回',
          icon: const Icon(Icons.arrow_back),
          onPressed: () {
            Navigator.of(context).pop('back');
          },
        ),
      ),
      body: Padding(
        padding: EdgeInsets.fromLTRB(10, 30, 0, 0),
        child: ListView(
          children: [
            Column(
              children: [
                Wrap(
                  spacing: 2, //主轴上子控件的间距
                  runSpacing: 5, //交叉轴上子控件之间的间距
                  children: [
                    Container(
                      width: textWidth,
                      child: Text(
                        "二维码:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    Container(
                      height: inputHeigt,
                      width: getFromWidth(),
                      color: Colors.black12,
                      child: TextField(
                        controller: new TextEditingController(),
                        onChanged: (value) {},
                        style: textStyle,
                        readOnly: true,
                        // focusNode: FocusNode(),
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black, width: 1.0),
                          ),
                        ),
                      )..controller!.text = qrCode,
                    ),
                    Container(
                      width: textWidth,
                      child: Text(
                        "生成时间:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    Container(
                      height: inputHeigt,
                      width: getFromWidth(),
                      color: Colors.black12,
                      child: TextField(
                        controller: new TextEditingController(),
                        onChanged: (value) {
                          print(value);
                        },
                        style: TextStyle(
                          fontSize: 10.0,
                        ),
                        readOnly: true,
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black, width: 1.0),
                          ),
                        ),
                      )..controller!.text = generateDate,
                    ),
                  ],
                ),
                SizedBox(
                  height: 10,
                ),
                // Row(
                //   children: [
                // Container(
                //   width: textWidth,
                //   child: Text(
                //     "生成时间:",
                //     style: textStyle,
                //     textAlign: TextAlign.end,
                //   ),
                // ),
                // Container(
                //   height: inputHeigt,
                //   width: 75,
                //   // color: Colors.amber,r
                //   // decoration: sty(

                //   // ),
                //   child: TextField(
                //     controller: new TextEditingController(),
                //     onChanged: (value) {
                //       print(value);
                //     },
                //     style: TextStyle(
                //       fontSize: 10.0,
                //     ),
                //     readOnly: true,
                //     decoration: InputDecoration(
                //       border: OutlineInputBorder(
                //         borderSide:
                //             BorderSide(color: Colors.black, width: 1.0),
                //       ),
                //     ),
                //   )..controller!.text = generateDate,
                // ),
                // SizedBox(
                //   width: 10,
                // ),
                // Container(
                //   width: textWidth,
                //   child: Text(
                //     "供应商编号:",
                //     textAlign: TextAlign.end,
                //     style: textStyle,
                //   ),
                // ),
                // Container(
                //   height: inputHeigt,
                //   width: 115,
                //   // color: Colors.amber,
                //   // decoration: sty(

                //   // ),
                //   child: TextField(
                //     controller: new TextEditingController(),
                //     onChanged: (value) {
                //       print(value);
                //     },
                //     readOnly: true,
                //     style: textStyle,
                //     decoration: InputDecoration(
                //       border: OutlineInputBorder(
                //         borderSide:
                //             BorderSide(color: Colors.black, width: 1.0),
                //       ),
                //     ),
                //   )..controller!.text = supplierNumber,
                // ),
                //   ],
                // ),
                // SizedBox(
                //   height: 10,
                // ),
                // Row(
                //   children: [
                // Container(
                //   width: textWidth,
                //   child: Text(
                //     "供应商名称:",
                //     style: textStyle,
                //     textAlign: TextAlign.end,
                //   ),
                // ),
                // Container(
                //   height: inputHeigt,
                //   width: 260,
                //   // color: Colors.amber,
                //   // decoration: sty(

                //   // ),r
                //   child: TextField(
                //     onChanged: (value) {
                //       print(value);
                //     },
                //     controller: new TextEditingController(),
                //     readOnly: true,
                //     style: textStyle,
                //     decoration: InputDecoration(
                //       border: OutlineInputBorder(
                //         borderSide:
                //             BorderSide(color: Colors.black, width: 1.0),
                //       ),
                //     ),
                //   )..controller!.text = supplierName,
                // ),
                //   ],
                // ),

                Wrap(
                  spacing: 2, //主轴上子控件的间距
                  runSpacing: 5, //交叉轴上子控件之间的间距
                  children: [
                    Container(
                      width: textWidth,
                      child: Text(
                        "商品条码:",
                        textAlign: TextAlign.end,
                        style: textStyle,
                      ),
                    ),
                    Container(
                      height: inputHeigt,
                      width: getFromWidth(),
                      color: disableColor,
                      child: TextField(
                        onChanged: (value) {
                          print(value);
                        },
                        controller: _goodsController,
                        focusNode: _goodsfocusNode,
                        style: textStyle,
                        readOnly: _isChange,
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black, width: 1.0),
                          ),
                          focusedBorder: Common.focusedBorder,
                        ),
                      ),
                    ),
                    Container(
                      width: 50,
                      child: Text(
                        "生产日期:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    // Container(
                    //   height: inputHeigt,
                    //   width: 130,
                    //   child: TextField(
                    //     onChanged: (value) {
                    //       print(value);
                    //     },
                    //     controller: new TextEditingController(),
                    //     style: textStyle,
                    //     readOnly: _isChange,
                    //     decoration: InputDecoration(
                    //       border: OutlineInputBorder(
                    //         borderSide:
                    //             BorderSide(color: Colors.black, width: 1.0),
                    //       ),
                    //     ),
                    //   )..controller!.text = productionDate,
                    // ),
                    Container(
                      height: 30,
                      width: getFromWidth(),
                      color: disableColor,
                      child: Container(
                        height: 30,
                        width: getIconWidth(),
                        decoration: BoxDecoration(
                          border: Border.all(color: Colors.black38, width: 1),
                          borderRadius: BorderRadius.vertical(
                            top: Radius.elliptical(4, 4),
                            bottom: Radius.elliptical(4, 4),
                          ),
                        ),
                        child: InkWell(
                          onTap: () => {
                            if (!_isChange)
                              {
                                _showDatePicker(),
                                print(_selectedDate),
                              }
                          },
                          child: Row(
                            children: <Widget>[
                              Container(
                                width: 10,
                              ),
                              Container(
                                width: getIconWidth(),
                                child: Text(
                                  productionDate,
                                  style: TextStyle(
                                    fontSize: 10,
                                  ),
                                ),
                              ),

                              // SizedBox(
                              //   width: 110,
                              // ),
                              Icon(
                                Icons.arrow_drop_down,
                              )
                            ],
                          ),
                        ),
                      ),
                    ),

                    // SizedBox(
                    //   width: 10,
                    // ),
                  ],
                ),

                // Row(
                //   children: [
                // Container(
                //   width: textWidth,
                //   child: Text(
                //     "规格:",
                //     style: textStyle,
                //     textAlign: TextAlign.end,
                //   ),
                // ),
                // Container(
                //   height: inputHeigt,
                //   width: 100,
                //   // color: Colors.amber,
                //   // decoration: sty(

                //   // ),
                //   child: TextField(
                //     onChanged: (value) {
                //       print(value);
                //     },
                //     controller: new TextEditingController(),
                //     style: textStyle,
                //     decoration: InputDecoration(
                //       border: OutlineInputBorder(
                //         borderSide:
                //             BorderSide(color: Colors.black, width: 1.0),
                //       ),
                //     ),
                //   )..controller!.text = norm,
                // ),
                //   ],
                // ),
                SizedBox(
                  height: 10,
                ),
                Wrap(
                  spacing: 2, //主轴上子控件的间距
                  runSpacing: 5,
                  children: [
                    Container(
                      width: textWidth,
                      child: Text(
                        "商品名称:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    Container(
                      height: inputHeigt,
                      width: getFromWidth(),
                      color: Colors.black12,
                      child: TextField(
                        onChanged: (value) {
                          print(value);
                        },
                        controller: new TextEditingController(),
                        readOnly: true,
                        style: textStyle,
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black, width: 1.0),
                          ),
                        ),
                      )..controller!.text = goodsName,
                    ),
                    Container(
                      width: textWidth,
                      child: Text(
                        "到期日期:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    Container(
                      height: inputHeigt,
                      width: getFromWidth(),
                      color: Colors.black12,
                      child: TextField(
                        onChanged: (value) {
                          print(value);
                        },
                        style: textStyle,
                        readOnly: true,
                        controller: new TextEditingController(),
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black, width: 1.0),
                          ),
                        ),
                      )..controller!.text = maturityDate,
                    ),
                    // Container(
                    //   width: 50,
                    //   child: Text(
                    //     "单位:",
                    //     textAlign: TextAlign.end,
                    //     style: textStyle,
                    //   ),
                    // ),
                    // Container(
                    //   height: inputHeigt,
                    //   width: 180,
                    //   color: disableColor,
                    //   child: TextField(
                    //     onChanged: (value) {
                    //       print(value);
                    //     },
                    //     controller: new TextEditingController(),
                    //     style: textStyle,
                    //     readOnly: _isChange,
                    //     decoration: InputDecoration(
                    //       border: OutlineInputBorder(
                    //         borderSide:
                    //             BorderSide(color: Colors.black, width: 1.0),
                    //       ),
                    //       focusedBorder: Common.focusedBorder,
                    //     ),
                    //   )..controller!.text = unit,
                    // ),
                  ],
                ),
                SizedBox(
                  height: 10,
                ),

                Wrap(
                  spacing: 2, //主轴上子控件的间距
                  runSpacing: 5,
                  alignment: WrapAlignment.start,
                  crossAxisAlignment: WrapCrossAlignment.start,
                  children: [
                    Container(
                      width: textWidth,
                      child: Text(
                        "保质期:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    Container(
                      height: inputHeigt,
                      width: getFromWidth(),
                      color: Colors.black12,
                      child: TextField(
                        keyboardType: TextInputType.number,
                        onChanged: (value) {
                          shelfLife = value;
                          print(value);
                        },
                        // controller: new TextEditingController(),
                        controller: _shelfLifeController,
                        focusNode: _shelfLifefocusNode,
                        style: textStyle,
                        // readOnly: _isChange,
                        readOnly: true,
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderSide:
                                BorderSide(color: Colors.black, width: 1.0),
                          ),
                          focusedBorder: Common.focusedBorder,
                        ),
                      ),
                    ),
                    Container(
                      width: 30,
                      child: Text(
                        '$shelfLifeUnit',
                        style: textStyle,
                        textAlign: TextAlign.start,
                      ),
                    ),
                    SizedBox(
                      width: getFromWidth() + 20,
                    )
                    // Container(
                    //   color: disableColor,
                    //   height: 25,
                    //   width: 85,
                    //   child: Container(
                    //     height: 25,
                    //     width: 85,
                    //     decoration: BoxDecoration(
                    //       border: Border.all(color: Colors.black38, width: 1),
                    //       borderRadius: BorderRadius.vertical(
                    //         top: Radius.elliptical(4, 4),
                    //         bottom: Radius.elliptical(4, 4),
                    //       ),
                    //     ),
                    //     child: DropdownButton(
                    //         value: _status,
                    //         icon: Icon(Icons.arrow_drop_down),
                    //         iconSize: 20,
                    //         iconEnabledColor: Colors.black.withOpacity(0.7),
                    //         hint: Text('请选择'),
                    //         style: TextStyle(color: Colors.black, fontSize: 12),
                    //         isExpanded: true,
                    //         underline: Container(color: Colors.white),
                    //         items: [
                    //           DropdownMenuItem(
                    //               child: Row(children: <Widget>[
                    //                 Text('天 '),
                    //                 SizedBox(width: 10),
                    //                 // Icon(Icons.ac_unit)
                    //               ]),
                    //               value: 0),
                    //           DropdownMenuItem(
                    //               child: Row(children: <Widget>[
                    //                 Text('个月 '),
                    //                 SizedBox(width: 10),
                    //                 // Icon(Icons.ac_unit)
                    //               ]),
                    //               value: 1),
                    //           DropdownMenuItem(
                    //               child: Row(children: <Widget>[
                    //                 Text('年'),
                    //                 SizedBox(width: 10),
                    //                 // Icon(Icons.ac_unit)
                    //               ]),
                    //               value: 2),
                    //         ],
                    //         onChanged: (value) {
                    //           setState(() => _status = value as int);
                    //           getMaturityDate();
                    //           print(value);
                    //         }),
                    //   ),
                    // ),

                    // Container(
                    //   width: 40,
                    //   child: Text(
                    //     "($shelfLifeUnit)",
                    //     style: textStyle,
                    //     textAlign: TextAlign.start,
                    //   ),
                    // ),
                    // Container(
                    //   width: textWidth,
                    //   child: Text(
                    //     "到期日期:",
                    //     style: textStyle,
                    //     textAlign: TextAlign.end,
                    //   ),
                    // ),
                    // Container(
                    //   height: inputHeigt,
                    //   width: 180,
                    //   color: Colors.black12,
                    //   child: TextField(
                    //     onChanged: (value) {
                    //       print(value);
                    //     },
                    //     style: textStyle,
                    //     readOnly: true,
                    //     controller: new TextEditingController(),
                    //     decoration: InputDecoration(
                    //       border: OutlineInputBorder(
                    //         borderSide:
                    //             BorderSide(color: Colors.black, width: 1.0),
                    //       ),
                    //     ),
                    //   )..controller!.text = maturityDate,
                    // ),
                  ],
                ),
                SizedBox(
                  height: 10,
                ),

                // Row(
                //   children: [
                //     Container(
                //       width: 50,
                //       child: Text(
                //         "产地:",
                //         style: textStyle,
                //         textAlign: TextAlign.end,
                //       ),
                //     ),
                //     Container(
                //       height: inputHeigt,
                //       color: disableColor,
                //       width: 450,
                //       child: TextField(
                //         onChanged: (value) {
                //           print(value);
                //         },
                //         controller: new TextEditingController(),
                //         style: textStyle,
                //         readOnly: _isChange,
                //         decoration: InputDecoration(
                //           border: OutlineInputBorder(
                //             borderSide:
                //                 BorderSide(color: Colors.black, width: 1.0),
                //           ),
                //           focusedBorder: Common.focusedBorder,
                //         ),
                //       )..controller!.text = generateLocation,
                //     ),
                //   ],
                // ),
                // Row(
                //   children: [
                //     Container(
                //       width: textWidth,
                //       child: Text(
                //         "生产商:",
                //         style: textStyle,
                //         textAlign: TextAlign.end,
                //       ),
                //     ),
                //     Container(
                //       height: inputHeigt,
                //       width: 260,
                //       // color: Colors.amber,
                //       // decoration: sty(

                //       // ),r
                //       child: TextField(
                //         onChanged: (value) {
                //           print(value);
                //         },
                //         controller: new TextEditingController(),
                //         style: textStyle,
                //         decoration: InputDecoration(
                //           border: OutlineInputBorder(
                //             borderSide:
                //                 BorderSide(color: Colors.black, width: 1.0),
                //           ),
                //         ),
                //       )..controller!.text = generateCompany,
                //     ),
                //   ],
                // ),
                SizedBox(
                  height: 10,
                ),

                Row(
                  children: [
                    Container(
                      width: textWidth,
                      child: Text(
                        "质检报告:",
                        style: textStyle,
                        textAlign: TextAlign.end,
                      ),
                    ),
                    Container(
                      height: 350,
                      width: getWidth(),

                      // color: Colors.white,
                      decoration: BoxDecoration(
                        border: Border.all(width: 1, color: Colors.grey),
                        // color: Colors.grey,
                      ),
                      child: Row(
                        children: [
                          Offstage(
                            offstage: _showImg,
                            child: Container(
                              child: Image.network(
                                // "https://tse4-mm.cn.bing.net/th/id/OIP-C.L1TCjzqXQxns3JiNNq2_pQHaEK?pid=ImgDet&rs=1",
                                checkImg,
                                height: 350,
                                width: getWidth() - 20,
                              ),
                            ),
                          ),
                          Offstage(
                            offstage: !_showImg,
                            child: Container(
                              height: 350,
                              width: getWidth() - 20,
                              child: Text(
                                "未查询到质检报告",
                                style: textStyle,
                                textAlign: TextAlign.center,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
                SizedBox(
                  height: 10,
                ),
                Center(
                    child: Container(
                  width: 100,
                  color: disableColor,
                  child: TextButton(
                    style: _buttonStyle,
                    child: Text(
                      "保存",
                      style: _buttonTextStyle,
                    ),
                    onPressed: () => {
                      if (!_isChange)
                        {
                          alertDialog("当天生产的同一商品都会同一被修正，请点确认修改。"),
                          print("保存"),
                        }
                      // print(this.listDataPage),
                    },
                  ),
                )),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
